package com.nononsenseapps.feeder.db.entity

import androidx.room.*
import com.gitee.wsl.struct.category.I_CategoryItem
import com.nononsenseapps.feeder.db.FEED_ITEM_TAG
import com.nononsenseapps.feeder.db.FEED_ITEM_TAG_ROOT_NAME
import com.nononsenseapps.feeder.db.room.ID_UNSET

@Entity(tableName = FEED_ITEM_TAG.tableName,
    indices = [Index(value = [FEED_ITEM_TAG.COL_NAME], unique = true)])
data class FeedItemTag  @Ignore constructor(
    @PrimaryKey(autoGenerate = true)
                  @ColumnInfo(name = FEED_ITEM_TAG.COL_ID) var id: Long = ID_UNSET,
    @ColumnInfo(name = FEED_ITEM_TAG.COL_NAME) var name :String = "",
    @ColumnInfo(name = FEED_ITEM_TAG.COL_PARENT_TAG) var parentTag :String = FEED_ITEM_TAG_ROOT_NAME,
    @ColumnInfo(name = FEED_ITEM_TAG.COL_ATTENTION_LEVEL) override var attentionLevel: Int = ATTENTION_NORMAL,
    @ColumnInfo(name = FEED_ITEM_TAG.COL_HOT) var hot: Boolean = false,
    @ColumnInfo(name = FEED_ITEM_TAG.COL_CLICK_COUNT) var clickCount: Int = 0
) : I_CategoryItem<String> {
    constructor() : this(id = ID_UNSET)

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (this::class != other!!::class) return false

        other as FeedItemTag

        if (id != other.id) return false

        return true
    }

    override fun hashCode(): Int {
        return id.hashCode()
    }

    @get:Ignore
    override val key: String
        get() = name

    @Ignore
    override var parentKey: String? = parentTag

    @get:Ignore
    override val title: String
        get() = name

    @Ignore
    override var isCategory: Boolean = false




}